﻿using log4net;
using Microsoft.Extensions.Logging;
using Serilog;

var builder = WebApplication.CreateBuilder(args);

#region 初始化日志
//builder.Host.ConfigureLogging(logging =>
//{
//    _ = logging.ClearProviders();
//    _ = logging.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);//过滤掉命名空间
//    _ = logging.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
//    _ = logging.AddLog4Net(System.IO.Directory.GetCurrentDirectory() + "/Config/log4.config");
//});

Log.Logger = new LoggerConfiguration().WriteTo.Console(outputTemplate: "🏢 MyCompany: {Message}{NewLine}")
            .CreateLogger();

Log.Information("This is a log message.");

Log.CloseAndFlush();

#endregion
// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
